<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateRecordBalancesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('record_balances', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('store_id')->index()->nullable()->comment('门店ID');
            $table->integer('member_id')->index()->nullable()->comment('会员ID');
            $table->integer('price')->index()->default(0)->comment('交易金额');
            $table->integer('type')->index()->default(1)->comment('交易方式:1.充值、2.支付');
            $table->integer('balance')->index()->default(1)->comment('剩余余额');
            $table->string('tables',190)->index()->default('orders')->comment('来源表名');
            $table->integer('order_id')->index()->nullable()->comment('来源ID');
            $table->integer('cashier_id')->index()->nullable(0)->comment('收银员ID');
            $table->string('description', '255')->nullable()->comment('交易描述');

            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('record_balances');
    }
}
